import 'package:aichat_flutter_wallet/module_common/utils/colors.dart';
import 'package:aichat_flutter_wallet/module_common/widgets/button/public_button.dart';
import 'package:aichat_flutter_wallet/module_common/widgets/dialog/bottom_sheet_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lib_language/lib_language.dart';

class ConnectAccount extends StatefulWidget {
  final String? title;
  Function? onConfrim;
  String address;
  String walletName;
  ConnectAccount({super.key, this.title, this.onConfrim, required this.walletName, required this.address});

  @override
  State<StatefulWidget> createState() {
    return _ConnectAccountState();
  }
}

class _ConnectAccountState extends State<ConnectAccount> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return BottomSheetWidget(
      title: widget.title ?? LocaleKeys.qingshuruqianbaomima.tr(),
      expand: false,
      child: Container(
        padding: EdgeInsets.symmetric(horizontal: 20.w),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            SizedBox(
              height: 10.w,
            ),
            Text(
              'Would you like to connect to this Dapp?',
              style: TextStyle(fontSize: 14.sp, color: AppColors.c_333333, fontWeight: FontWeight.w500),
            ),
            SizedBox(
              height: 10.w,
            ),
            Container(
              padding: EdgeInsets.all(12.w),
              decoration: BoxDecoration(color: AppColors.c_FFF8F1, borderRadius: BorderRadius.all(Radius.circular(10))),
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Image.asset(
                    'assets/images/dapp/warn.png',
                    width: 20.w,
                    height: 20.w,
                  ),
                  SizedBox(
                    width: 10.w,
                  ),
                  Expanded(
                      flex: 1,
                      child: Text(
                        "Click 'Connect' to indicate that you allow the decentralized application to access your account address, balance, and activity. This is an important step to protect your data and guard against phishing risks.",
                        softWrap: true,
                        style: TextStyle(
                            fontSize: 12.sp,
                            fontWeight: FontWeight.w400,
                            color: AppColors.c_FF5100,
                            height: 16.w / 12.w),
                      ))
                ],
              ),
            ),
            SizedBox(
              height: 20.w,
            ),
            Container(
              width: double.infinity,
              padding: EdgeInsets.all(12.w),
              decoration: BoxDecoration(
                border: Border.all(width: 1.w, color: AppColors.c_E0E0E0),
                borderRadius: BorderRadius.all(Radius.circular(10.w)),
              ),
              child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
                Text(
                  widget.walletName,
                  style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, color: AppColors.c_333333),
                ),
                SizedBox(
                  height: 2.w,
                ),
                Text(
                  widget.address,
                  style: TextStyle(fontSize: 10.sp, fontWeight: FontWeight.w400, color: AppColors.c_BEBDCA),
                )
              ]),
            ),
            SizedBox(
              height: 20.w,
            ),
            Container(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Expanded(
                      child: PublicButton(
                          margin: EdgeInsets.zero,
                          type: ButtonType.defaultType,
                          text: 'Cancel',
                          onClick: () {
                            Navigator.of(context).pop(false);
                          })),
                  SizedBox(
                    width: 20.w,
                  ),
                  Expanded(
                      child: PublicButton(
                    margin: EdgeInsets.zero,
                    type: ButtonType.private,
                    text: 'Comfirm',
                    onClick: () async {
                      Navigator.of(context).pop(true);
                    },
                  ))
                ],
              ),
            ),
            SizedBox(
              height: 10.w + MediaQuery.of(context).padding.bottom.w,
            ),
          ],
        ),
      ),
    );
  }
}
